<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>公告管理liebia</title>
<link rel="stylesheet" type="text/css" href="../extjs_all/resources/css/ext-all.css"></link>
<script type="text/javascript" src="../extjs_all/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../extjs_all/ext-all-debug.js"></script>
<script type="text/javascript" src="../extjs_all/ext-all.js"></script>
<script type="text/javascript"
	src="../js/libs/ext/adapter/ext/ext-lang-zh_CN.js">
	
</script>


<script type="text/javascript">

	Ext.onReady(function() {
		var gridStr;
		<s:if test="data!=null">
			gridStr=<s:property value="data"/>;
		</s:if>	
		
		//在表格中添加选择框
		var sm = new Ext.grid.CheckboxSelectionModel();
		
		var cm = new Ext.grid.ColumnModel( [

		new Ext.grid.RowNumberer(),//自动行号
		sm,//添加的地方
		                                		
		{
			header : '主标题',
			dataIndex : 'title',
			sortable : true
		}, {
			header : '副标题',
			dataIndex : 'sec_title'
		}, {
			header : '公告类型',
			dataIndex : 'sortname'
		} , {
			header : '报告类型',
			dataIndex : 'czbgtype'
		}, {
			header : '审计人',
			dataIndex : 'auditer'
		}, {
			header : '审计时间',
			dataIndex : 'audit_time'
		}, {
			header : '状态',
			dataIndex : 'state'
		}]);
		var data = [ 
		    		[ '1', 'name1', 'descn1' ],
		    		[ '2', 'name2', 'descn2' ],
				[ '3', 'name3', 'descn3' ], [ '4', 'name4', 'descn4' ],
				[ '5', 'name3', 'descn5' ] ];
		var ds = new Ext.data.Store( {
			proxy : new Ext.data.MemoryProxy(data),
			reader : new Ext.data.ArrayReader( {}, [ {
				name : 'title'
			}, {
				name : 'sec_title'
			}, {
				name : 'sortname'
			}, {
				name : 'czbgtype'
			}, {
				name : 'auditer'
			}, {
				name : 'audit_time'
			}, {
				name : 'state'
			}])
		});
		ds.load();
		var win;
		var grid = new Ext.grid.GridPanel( {
			width:800, 
		  height:300,
		  title: '公告列表',
			el : 'grid',
			ds : ds,
			cm : cm,
			bbar: new Ext.PagingToolbar({
            pageSize: 10,
            store: ds,
            displayInfo: true,
            displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
            emptyMsg: "没有记录"
        }),

			tbar:[{
				            text: '添加',
				            icon: '../../resources/images/add.gif',
				            iconCls:'add',
				            //静态的超链接
				            handler : function(){
				            	
        // create the window on the first click and reuse on subsequent clicks
        if(!win){
            win = new Ext.Window({
                applyTo     : 'hello-win',
                layout      : 'fit',
                width       : 400,
                height      : 350,
                closeAction :'hide',
                plain       : true,
                items       : new Ext.FormPanel({
						        frame: true,
						        title:'新增公告',
						        labelAlign: 'right',
						        labelWidth: 85,
						        width:340,
						        waitMsgTarget: true,
						        items: [
            new Ext.form.FieldSet({
            	id:"formid",
                title: 'Notice Information',
                autoHeight: true,
                defaultType: 'textfield',
                items: [{
                        fieldLabel: '标题',
                        name: 'title',
                        width:190
                    }, {
                        fieldLabel: '副标题',
                        name: 'sec_title',
                        width:190
                    },
                    new Ext.form.ComboBox({
                        fieldLabel: '公告类型',
                        hiddenName:'sortname',
                        store: new Ext.data.SimpleStore({
                            fields: ['abbr', 'state'],
                            data : [['公告','公告'],['定期报告','定期报告'],['公司治理','公司治理'],['会议召集','会议召集'],['新股上市','新股上市']]
                        }),
                        valueField:'abbr',
                        displayField:'state',
                        typeAhead: true,
                        mode: 'local',
                        triggerAction: 'all',
                      //  emptyText:'Select a state...',
                        selectOnFocus:true,
                        width:190
                    }),
                    new Ext.form.ComboBox({
                        fieldLabel: '报告类型',
                        hiddenName:'czbgtype',
                        store: new Ext.data.SimpleStore({
                            fields: ['abbr', 'state'],
                            data : [['季度','季度'],['半年度','半年度'],['年度','年度']]
                        }),
                        valueField:'abbr',
                        displayField:'state',
                        typeAhead: true,
                        mode: 'local',
                        triggerAction: 'all',
                      //  emptyText:'Select a state...',
                        selectOnFocus:true,
                        width:190
                    }),
                     {
                        fieldLabel: '审计人',
                        name: 'auditer',
                        width:190
                    },
                    new Ext.form.DateField({
                        fieldLabel: '审计时间',
                        name: 'audit_time',
                        width:190,
                        allowBlank:false
                    }),{
							        xtype : 'textfield',
							        fieldLabel : '上传文件名',
							        name : 'userfile',
							        id : 'userfile',
							        inputType : 'file',
							        blankText : 'File can\'t not empty.',
							        anchor : '100%' // anchor width by percentage
							       }

                    
                ]
            })
        ]
                }),

                buttons: [{
                    text     : '提交',
                    //disabled : true
                    handler	 :function(){
                    	alert("提交！");	
                   // location.href="add.action";
                    //	Ext.getCmp('formid').getForm().getEl().dom.action='add.action';
				     //   Ext.getCmp('formid').getForm().getEl().dom.submit();
                    } 
                },{
                    text     : 'Close',
                    handler  : function(){
                        win.hide();
                    }
                }]
            });
        }
        win.show();
   
				            	//location.href="addInit.action";
					            }
				       		},{
					        text:'修改',
					        icon: '../../resources/images/plugin.gif', 
					        iconCls:'option',
					        handler:function(){
				       			var record ="";
				       			record= grid.getSelectionModel().getSelected();
				       			if(null == record ){
									Ext.MessageBox.alert('提示','请选择要修改的数据！');
								}else{
					       			var feDictionaryId = record.get("id");
					       			    Ext.getCmp('feDictionaryId').setValue(feDictionaryId);
										Ext.getCmp('formbuttons').getForm().getEl().dom.action='toupdate.action';
								        Ext.getCmp('formbuttons').getForm().getEl().dom.submit();
									}
						        }
					        },{
				            text: '删除',
				            icon: '../../resources/images/add.gif',
				            iconCls:'add',
				            //静态的超链接
				            handler : function(){
				            	location.href="addInit.action";
					            }
				       		}]
		});
		grid.render();
	});
	

</script>
</head>
<body>
	<div id="grid1" ></div>
<div id="grid" ></div>
<div id="hello-win" class="x-hidden"></div>
</body>
</html>
<!--http://apps.hi.baidu.com/share/detail/2866491-->
<!--http://www.blogjava.net/Reg/archive/2010/01/20/310266.html-->

